<?php

// Path aliases
Yii::setPathOfAlias('apps', dirname(__FILE__) . '/../../../apps');
Yii::setPathOfAlias('common', dirname(__FILE__) . '/../../../common/');

// Load environment config
$envConfig = require (dirname(__FILE__) . '/' . ENVIRONMENT . '/extra.php');


// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
$main = array(
    'id' => 'propsage',
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '../',
    'name' => 'PropSage.com',
    // preloading 'log' component
    'preload' => array('log'),
    // autoloading model and component classes
    'import' => array(
        'common.models.*',
        'common.components.*',
        'common.components.utils.*',
        'common.lib.*',
        'application.models.*',
        'application.components.*',
        'application.extensions.*',
        'application.widgets.*',
    ),
    'modules' => array(
//        'sms',
        'tickets' => array('class' => 'application.modules.tickets_public.TicketsModule'),
    ),
    // application components
    'components' => array(
        'db' => require(dirname(__FILE__) . '/../../../common/config/' . ENVIRONMENT . '/db.php'),
		'authManager' => array(
			'class' => 'PsDbAuthManager',
			'assignmentTable' => 'user_auth_assignment',
			'itemTable' => 'user_auth_item',
			'itemChildTable' => 'user_auth_item_child',
		),
        'clientScript' => array(
            'class' => 'PsClientScript',
            'version' => version(),
            'packages' => array(
                'jquery' => array(
                    'baseUrl' => '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/',
                    'js' => array('jquery.min.js'),
                ),
            )
        ),    
        'assetManager' => array(
            'class' => 'PsAssetManager',
        ),
//        'maintenanceMode' => require dirname(__FILE__) . '/maintenance.php',
        'systemConfig' => array(
            'class' => 'PsSystemConfig',
        ),
        'user' => array(
            'class' => 'PsWebUser', // use custom CWebUser class
            'allowAutoLogin' => true, // enable cookie-based authentication
            'autoRenewCookie' => true,
            'loginUrl' => array('/account/login'),
        ),
        'mailer' => array(
            'class' => 'application.extensions.mailer.EMailer',
            'pathViews' => 'application.views.email',
            'pathLayouts' => 'application.views.email.layouts'
        ),
//        'sprite' => array(
//            'class' => 'common.lib.sprite.NSprite',
//            // if you remove the imageFolderPsth setting it will use the icon folder within   
//            // the sprite package (common.lib.sprite.icons)
//            'imageFolderPath' => array(
//                'webroot.images.icons',
//            ),
//        ),
        // uncomment the following to enable URLs in path-format
        'urlManager' => array(
            'urlFormat' => 'path',
            'showScriptName' => false,
            'rules' => array(
                // Custom URL rules
                'signup' => 'account/identify',
                'login' => 'account/login',
                'login/<shortname:\w+>' => '/account/login/shortname/<shortname>',
                'help' => 'site/contact',
				'cfc' => 'site/cfc',
				// Ticket controller shortcut
				'<shortname:\w+>/tickets' => 'tickets/index/shortname/<shortname>',
				'<shortname:\w+>/tickets/<action:\w+>/ticket_number/<ticket_number>/email/<email>' => 'tickets/<action>/shortname/<shortname>/ticket_number/<ticket_number>/email/<email>',
				'<shortname:\w+>/tickets/<action:\w+>' => 'tickets/<action>/shortname/<shortname>',
                // Agency login shortcut
                'agentLogin/<shortname:\w+>' => '/account/agentLogin/shortname/<shortname>',
                'agencyLogin/<shortname:\w+>' => '/account/agencyLogin/shortname/<shortname>',
                // Referral URLs shortening
                'r/<id:\w+>' => '/account/identify/referrer/<id>',
                // Video URLs
                'getFile/<vid:\d+>_<lang:\w+>_<token:\w+>.flv' => 'getFile/flv',
                'getFile/<vid:\d+>_<lang:\w+>_<token:\w+>.mov' => 'getFile/mov',
                'getFile/<vid:\d+>_<lang:\w+>_<token:\w+>.m4v' => 'getFile/m4v',
				// Thumbnails
				array('/thumbs/index', 'pattern'=> 'thumbs/<uuid>/<thumb_width:\d+>x<thumb_height:\d+><crop_mode:(F|)>/<file>\.<ext:(gif|jpg|jpeg|png)>', 'caseSensitive' => false),
				array('/thumbs/index', 'pattern'=> 'uploads/<uuid>/<thumb_width:\d+>x<thumb_height:\d+><crop_mode:(F|)>/<file>\.<ext:(gif|jpg|jpeg|png)>', 'caseSensitive' => false),
                // Static Page
                '<id:\w+>.html' => 'site/page/view/<id>',
                // REST patterns
                array('rest/<model>Api/list', 'pattern' => 'api/<model:\w+>', 'verb' => 'GET'),
                array('rest/<model>Api/view', 'pattern' => 'api/<model:\w+>/<id:\w+>', 'verb' => 'GET'),
                array('rest/<model>Api/update', 'pattern' => 'api/<model:\w+>/<id:\w+>', 'verb' => 'PUT'),
                array('rest/<model>Api/delete', 'pattern' => 'api/<model:\w+>/<id:\w+>', 'verb' => 'DELETE'),
                array('rest/<model>Api/create', 'pattern' => 'api/<model:\w+>', 'verb' => 'POST'),
                // Standard URL rules
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            ),
        ),
        'errorHandler' => array(
            // use 'site/error' action to display errors
            'errorAction' => 'site/error',
        ),
        'mailer' => array(
            'class' => 'common.lib',
        )
    ),
    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    'params' => array(
        'creditExpiryLimit' => 365, //days
        'calReminderEmail' => 'calendar-noreply@propsage.com',
        'calReminderName' => 'PropSage Calendar',
        'referralBonus' => 5.00,
        'signupBonus' => 7.00,
        'videoPlaybackLimit' => 3,
        // Paypal sandbox settings
        'paypalSandboxEmail' => 'cform_1302059987_biz@smartvirtualoffice.com.sg',
        'paypalSandboxUrl' => 'https://www.sandbox.paypal.com/cgi-bin/webscr',
        // Real Paypal settings
        'GSTRate' => 0, // 7.00%
        'paypalEmail' => 'paypal@propsage.com',
        'paypalUrl' => 'https://www.paypal.com/cgi-bin/webscr',
    ),
);


//merge both configurations
return CMap::mergeArray($main, $envConfig);